<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <script>
    function flat(arr) {
      let result = [];
      for (let item of arr) {
        Array.isArray(item) ? result.push(...flat(item)) : result.push(item);
      }
      return result;
    }

    console.log(flat([1, 3, 4, [5, 6, 7, [2, 3, [9, [10]]]]]));
  </script>
  <body></body>
</html>
